package service;

import bean.Dept;
import bean.Emp;
import mapper.DeptMapper;
import mapper.EmpMapper;

import java.io.IOException;
import java.util.Set;

public class DeptService extends BaseService{
    private DeptMapper deptMapper;
    private EmpMapper empMapper;
    public  DeptService(){
        try {
            deptMapper=getMapper(DeptMapper.class);
            empMapper=getMapper(EmpMapper.class);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public Dept find(int id){
        return deptMapper.findDeptByNo2(id);
    }

    public Dept find2(int id){
        Dept dept=deptMapper.findDeptByNo3(id);
        Set<Emp> empSet=empMapper.findEmpByDeptNo(id);
        dept.setEmpSet(empSet);
        return dept;
    }
}
